package com.coconet.gas.until;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;

import com.coconet.gas.constant.RotdrCommond;

public class run {
	public static void main(String[] args) throws IOException {
		SocketChannel sChannel = SocketChannel.open(new InetSocketAddress("192.168.8.101", 6666));
		CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder();
		encoder = Charset.forName("UTF-8").newEncoder();
		sChannel.write(encoder.encode(CharBuffer.wrap(RotdrCommond.GETTEMPERATURE.getDesc()+"\r\n")));
		ByteBuffer buf = ByteBuffer.allocate(50);
		int code;
//		while ((code = sChannel.read(buf)) != -1) {
//			sChannel.read(buf);
//			if (new String(buf.array()).contains("compeleted")) {
//				break;
//			}
//			
//		}
		while (buf.hasRemaining()) {
		sChannel.read(buf);
		
		
	}
		System.err.println(new String(buf.array()));
	}
}
